<template>
    <div class="container" @click="handleGallaryClick">
      <div class="wiapper">
        <!--     v-if="swiperList.length" 解决轮播图显示最后一页的问题，当真正的数据过来之后再进行创建 -->
<!--            <swiper ref="mySwiper" :options="swiperOptions" v-if="swiperList.length">-->
        <swiper ref="mySwiper" :options="swiperOptions">
          <swiper-slide v-for="(item, index) in imgs" :key="index">
            <img class="swiper-img" :src="item" alt="北京环球度假区"/>
          </swiper-slide>
          <div class="swiper-pagination" slot="pagination"></div>
        </swiper>
      </div>
    </div>
</template>

<script>
export default {
  name: 'Gallary',
  props: {
    imgs: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      swiperOptions: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        // 以下两个参数 当swiper的祖先元素发生变化时 swiper进行更新
        observeParents: true,
        // 当改变swiper的样式（例如隐藏/显示）或者修改swiper的子元素时，自动初始化swiper。
        observer: true
      }
    }
  },
  methods: {
    handleGallaryClick () {
      this.$emit('close')
    }
  }
}
</script>

<style scoped lang="stylus">
  .container >>> .swiper-container
    overflow inherit
  .container
    position fixed
    z-index 9
    top 0
    left 0
    right: 0
    bottom 0
    display flex
    flex-direction column
    justify-content center
    background-color #000
    .wiapper
      width 100%
      height 0
      padding-bottom 100%
      .swiper-img
        width 100%
      .swiper-pagination
        color #ffffff
        bottom -2rem
</style>
